<?php
namespace Bshop\Controller;
use Think\Controller;
class CkadminController extends Controller{
	public function __construct(){
		parent::__construct();
		if(!isset($_SESSION['bxd_shop_user_id']) || empty($_SESSION['bxd_shop_user_id'])){
			$url=__APP__."/".MODULE_NAME."/Login/login";
			echo "<script language='javascript'>";
			echo "parent.parent.location='$url'";
			echo "</script>";die();
		}else{
			/*  if($_SESSION['eventor_admin_role_name']!="超级管理员"){
				$action_name = ACTION_NAME;
				$model_name = CONTROLLER_NAME;
				$rights = $model_name."@".$action_name;
				if($model_name!="Index" && $model_name!="Reuse"){
					if(stripos($_SESSION['eventor_admin_rights_name'],$rights)===false){
						$this->display('Index/home');
						echo alert("你没有权限来操作此目录",__APP__."/",1);die;
					}
				}
			}  */
		}
	}
	/**
	 * 添加操作日志
	 * @param unknown $log
	 */
	public function add_log($log){
		$data['operation_id'] = $_SESSION['hjyz_oa_admin_id'];
		$data['log'] = $log;
		M('operation_log')->add($data);
	}
	/**
	 * 查看商家人员信息
	 */
	public function admin_name($uid){
		$db = M('shop');
		$name = $db->where("id='$uid'")->find();
		return $name;
	}
	/**
	 * 生成主键--uuid
	 */
	public function parekey($model){
		$db = M($model);
		for($k=0;$k<=150000000;$k++){
			$uuid = \Org\Util\String::uuid();
			$re = $db->where(array('id'=>$uuid))->find();
			if(empty($re)){
				break;
			}else{
			}
		}
		return $uuid;
	}
	/**
	 * 隐藏信息
	 */
	public function hide_name($name){
		$length = strlen($name);
		if($length<=4){
			$newname = substr($name,0,2)."****";
		}elseif ($length>12){
			$newname = substr($name,0,4)."******".substr($name,10,$length);
		}else{
			$newname = substr($name,0,4)."****";
		}
		return $newname;
	}
}